package io.renren.modules.lucky.controller;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.modules.lucky.entity.AppGoodsAddrEntity;
import io.renren.modules.lucky.service.AppGoodsAddrService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;

/**
 * app端-商品-地址信息表
 *
 * @author chenshun
 * @email chenchen@ashacker.com
 * @date 2019-08-31 20:58:28
 */
@RestController
@RequestMapping("lucky/appgoodsaddr")
public class AppGoodsAddrController {

    @Autowired
    private AppGoodsAddrService appGoodsAddrService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("lucky:appgoodsaddr:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = appGoodsAddrService.queryPage(params);
        return R.ok().put("page", page);
    }

    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("lucky:appgoodsaddr:info")
    public R info(@PathVariable("id") Integer id){
		AppGoodsAddrEntity appGoodsAddr = appGoodsAddrService.getById(id);
        return R.ok().put("appgoodsaddr", appGoodsAddr);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("lucky:appgoodsaddr:save")
    public R save(@RequestBody AppGoodsAddrEntity appGoodsAddr){
		appGoodsAddrService.save(appGoodsAddr);
        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("lucky:appgoodsaddr:update")
    public R update(@RequestBody AppGoodsAddrEntity appGoodsAddr){
		appGoodsAddrService.updateById(appGoodsAddr);
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("lucky:appgoodsaddr:delete")
    public R delete(@RequestBody Integer[] ids){
		appGoodsAddrService.removeByIds(Arrays.asList(ids));
        return R.ok();
    }

}
